/** 
 * 启动qiankun框架，导出action和手动加载子应用的方法
 * 
 * */ 
import { registerMicroApps, start, setDefaultMountApp, initGlobalState, loadMicroApp} from 'qiankun';

export default function initQiankun({ apps = [], state, startOption, defaultApp }){
    const actions = initGlobalState(state);
    // actions.onGlobalStateChange((state, prev) => {
    //     // state: 变更后的状态; prev 变更前的状态
    //     console.log('这是主应用', state, prev);
    // }, true);
    // actions.setGlobalState(msg);
    // actions.offGlobalStateChange();

    // 默认加载的子应用
    defaultApp && setDefaultMountApp(defaultApp)
    registerMicroApps(apps)
    start(startOption);
    return {
        actions,
        loadMicroApp
    }
}